<?php

function dibujar_select($elementos = null,$value,$label,$id_select,$selectedvalue=null,$defaultvalue=null,$defaultlabel=null){
	
	echo '<select id="'.$id_select.'">';
	if(!empty($defaultlabel)){
		$selected = empty($selectedvalue) or $selectedvalue == $defaultvalue? ' selected="selected" ': '';
		echo '<option value="'.$defaultvalue.'" '. $selected.'  >'. $defaultlabel .'</option>';
	}
	if(!empty($elementos)){
		
		foreach ($elementos as $elemento){
			$selected = !empty($selectedvalue) and $selectedvalue == $defaultvalue? ' selected="selected" ': '';
			echo '<option value="'.$elemento[$value].'" '. $selected.' >'. $elemento[$label] .'</option>';
		}
	}
	echo '</select>';
}

?>